﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace SanguoSharp
{
    public interface ISession : IIdentificable
    {
        /// <summary>
        /// Gets the name of the session.
        /// </summary>
        string Name { get; }
        /// <summary>
        /// Gets the desription of the session.
        /// </summary>
        string Description { get; }
        /// <summary>
        /// Gets the current state of the session.
        /// </summary>
        SessionState State { get; }

        /// <summary>
        /// Gets the minimum number of players in this session to start a game.
        /// </summary>
        int MinPlayers { get; }
        /// <summary>
        /// Gets the maximum number of players in this session.
        /// </summary>
        int MaxPlayers { get; }
        /// <summary>
        /// Gets the maximum number of spectators in this session.
        /// </summary>
        int MaxSpectators { get; }
        /// <summary>
        /// Gets a value indicating wheter the session is password protected for players.
        /// </summary>
        bool HasPlayerPassword { get; }
        /// <summary>
        /// Gets a value indicating wheter the session is password protected for spectators.
        /// </summary>
        bool HasSpectatorPassword { get; }
        /// <summary>
        /// Gets the id of the creator of the session.
        /// </summary>
        IPlayer Creator { get; }

        /// <summary>
        /// Gets a value indicating wheter the Dodge City extension is active in the session.
        /// </summary>
        bool ExEx { get; }
        /// <summary>
        /// Gets a value indicating wheter the High Noon extension is active in the session.
        /// </summary>
        bool ExWind { get; }
        /// <summary>
        /// Gets a value indicating wheter the Fistful of Cards extension is active in the session.
        /// </summary>
        bool ExFire { get; }
        /// <summary>
        /// Gets a value indicating wheter the Wild West Show extension is active in the session.
        /// </summary>
        bool ExForest { get; }

        bool ExArmy { get; }

        /// <summary>
        /// Gets the number of games that have been played in this session.
        /// </summary>
        int GamesPlayed { get; }

        /// <summary>
        /// Gets the collection of players in the session.
        /// </summary>
        ReadOnlyCollection<IPlayer> Players { get; }
        /// <summary>
        /// Gets the collection of spectators in the session.
        /// </summary>
        ReadOnlyCollection<ISpectator> Spectators { get; }

        /// <summary>
        /// Joins a new player to the session.
        /// </summary>
        /// <param name="password">
        /// The session password.
        /// </param>
        /// <param name="data">
        /// The <see cref="CreatePlayerData"/> contatining the information about the player.
        /// </param>
        /// <param name="listener">
        /// The <see cref="PlayerEventListener"/> of the player.
        /// </param>
        void Join(Password password, CreatePlayerData data, IPlayerEventListener listener);
        /// <summary>
        /// Replaces an existing player with a new one. Only players without controller or AI players can be replaced.
        /// </summary>
        /// <param name="id">
        /// The ID of th player to be replaced.
        /// </param>
        /// <param name="password">
        /// The session password.
        /// </param>
        /// <param name="data">
        /// The <see cref="CreatePlayerData"/> contatining the information about the new player.
        /// </param>
        /// <param name="listener">
        /// The <see cref="PlayerEventListener"/> of the new player.
        /// </param>
        void Replace(int id, Password password, CreatePlayerData data, IPlayerEventListener listener);
        /// <summary>
        /// Joins a new spectator to the session.
        /// </summary>
        /// <param name="password">
        /// The session password.
        /// </param>
        /// <param name="data">
        /// The <see cref="CreateSpectatorData"/> contatining the information about the spectator.
        /// </param>
        /// <param name="listener">
        /// The <see cref="SpectatorEventListener"/> of the spectator.
        /// </param>
        void Spectate(Password password, CreateSpectatorData data, ISpectatorEventListener listener);
        /// <summary>
        /// Gets the player with the specified ID.
        /// </summary>
        /// <param name="id">
        /// The ID of the player.
        /// </param>
        /// <returns>
        /// The <see cref="IPlayer"/> instance representing the player.
        /// </returns>
        IPlayer GetPlayer(int id);
        /// <summary>
        /// Gets the spectator with the specified ID.
        /// </summary>
        /// <param name="id">
        /// The ID of the spectator.
        /// </param>
        /// <returns>
        /// The <see cref="IPlayer"/> instance representing the spectator.
        /// </returns>
        ISpectator GetSpectator(int id);
    }
}
